<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        //function Test() {
        //  this.name = name;
        //  this.age = age;
        //}
        //obj = {}
        obj = {}
        // Test.apply(obj,[name='狗狗',age=5])
        Test.call(obj, name = '狗狗', age = 5)
        console.log(obj);

        // 分别使用call，apply为obj添加name，age属性

        // 实现陈鹏买车，其中有sayHi方法，功能:打印'陈鹏买了一辆红色的2.0宝马车'

        // 父类Shape （属性有: name, length, width, 方法有:Intro 我是XX形）
        // 子类： Circle(属性有: r)

        // 分别使用 原型链继承 构造函数继承 圣杯继承

        function Shape() { }
        function Circle() { }
        Shape.prototype.name = 'dog'
        var shape = new Shape();
        Circle.prototype = shape;
        var circle = new Circle();
        circle.__proto__.r = '18';
        console.log(circle.r);


        function Shape(name) {
            this.name = name
        }
        function Circle(r, name) {

            Shape.call(this, name)
            this.r = r
        }
        var circle = new Circle(6, 'cat')

        console.log(circle.name);


        function Shape() { }
        function Circle() { }
        Shape.prototype.name = 'mouse'
        function inherit(Target, Origin) {
            function f() { }
            f.prototype = Origin.prototype;
            Target.prototype = new f()
            Target.prototype.constructor = Target;
            Target.prototype.uber = Origin;
        }
        inherit(Circle, Shape);
        var circle = new Circle();
        console.log(circle);
    </script>
</body>

</html>